package com.gg.hj.controller;

import com.gg.common.pojo.DFile;
import com.gg.common.pojo.SPay;
import com.gg.common.pojo.SPayDetails;
import com.gg.hj.search.SPaySearch;
import com.gg.hj.service.SPayService;
import com.gg.hj.view.SPayDetailsView;
import com.gg.hj.view.SPayDetailsVo;
import com.gg.hj.view.SPayView;
import com.gg.zjj.util.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class SPayController {
    @Resource
    private SPayService sPayService;

    //TODO 出库申请登记
    @ResponseBody
    @RequestMapping("/hj/queryWarehouseRegistration.action")
    public Result<List<DFile>> queryWarehouseRegistration() throws Exception {
        return Result.success(this.sPayService.queryWarehouseRegistrationService());
    }
    //TODO 添加出库申请登记
    @ResponseBody
    @RequestMapping("/hj/saveWarehouseRegistration.action")
    public Result saveWarehouseRegistration(@RequestBody SPayView sPayView) throws Exception {
        this.sPayService.saveWarehouseRegistrationService(sPayView);
        return Result.success();
    }
    //TODO 查询出库申请登记审核
    @ResponseBody
    @RequestMapping("/hj/queryWarehouseAuditing.action")
    public SPaySearch<SPay> queryWarehouseAuditing  (@RequestBody SPaySearch<SPay> sPaySPaySearch) throws Exception {
        return this.sPayService.queryWarehouseAuditingService(sPaySPaySearch);
    }
    //TODO 审核 查询出库明细
    @ResponseBody
    @RequestMapping("/hj/queryWarehouseDetail.action")
    public List<SPayDetailsVo> queryWarehouseDetail(int id) throws Exception {
        System.out.println("------------"+this.sPayService.queryWarehouseDetailService(id));
        return this.sPayService.queryWarehouseDetailService(id);
    }
    //TODO 审核 通过或不通过
    @ResponseBody
    @RequestMapping("/hj/warehouseCheck.action")
    public int warehouseCheck(@RequestBody SPay sPay) throws Exception {
        return this.sPayService.warehouseCheckService(sPay);
    }

    //TODO 出库申请查询
    @ResponseBody
    @RequestMapping("/hj/queryWarehouse.action")
    public SPaySearch<SPay> queryWarehouse(@RequestBody SPaySearch<SPay> sPaySPaySearch) throws Exception {
        return this.sPayService.queryWarehouseService(sPaySPaySearch);
    }
    //TODO 查询审核已通过库存单
    @ResponseBody
    @RequestMapping("/hj/queryWarehouseCheckTagApprove.action")
    public SPaySearch<SPay> queryWarehouseCheckTagApprove(@RequestBody SPaySearch<SPay> sPaySPaySearch) throws Exception {
        return this.sPayService.queryWarehouseCheckTagApproveService(sPaySPaySearch);
    }
    //TODO 根据父级序号查询出库明细 制定出库单
    @ResponseBody
    @RequestMapping("/hj/queryWarehouseDetailById.action")
    public List<SPayDetails> queryWarehouseDetailById(int id) throws Exception {
        return this.sPayService.queryWarehouseDetailById(id);
    }
    //TODO 查询出库明细 安全库存数量 调度
    @ResponseBody
    @RequestMapping("/hj/queryWarehouseDispatchDetail.action")
    public SPayDetailsVo queryWarehouseDispatchDetail(int id) throws Exception {
        return this.sPayService.queryWarehouseDispatchDetailService(id);
    }
    //TODO 修改调度产品 已调度
    @ResponseBody
    @RequestMapping("/hj/updateWarehouseDispatchDetail.action")
    public int updateWarehouseDispatchDetail(@RequestBody SPayView sPayView) throws Exception {
        return this.sPayService.updateWarehouseDispatchDetailService(sPayView);
    }

    //TODO 查询已调度出库单
    @ResponseBody
    @RequestMapping("/hj/queryWarehouseScheduled.action")
    public SPaySearch<SPay> queryWarehouseScheduled(@RequestBody SPaySearch<SPay> sPaySearch) throws Exception {
        return this.sPayService.queryWarehouseScheduledService(sPaySearch);
    }
    //TODO 根据父级序号查询产品 出库单
    @ResponseBody
    @RequestMapping("/hj/queryOutboundDeliveryOrder.action")
    public SPayDetailsView queryOutboundDeliveryOrder(int id) throws Exception {
        return this.sPayService.queryOutboundDeliveryOrderService(id);
    }
    //TODO  提交出库单 修改
    @ResponseBody
    @RequestMapping("/hj/updateWarehouseScheduled.action")
    public int updateWarehouseScheduled(@RequestBody SPayView sPayView) throws Exception {
        return this.sPayService.updateWarehouseScheduledService(sPayView);
    }
    //TODO  查询已登记出库单
    @ResponseBody
    @RequestMapping("/hj/queryWarehouseRegistrationCheck.action")
    public SPaySearch<SPay> queryWarehouseRegistrationCheck(@RequestBody SPaySearch<SPay> sPaySearch) throws Exception {
        return this.sPayService.queryWarehouseRegistrationCheckService(sPaySearch);
    }
    //TODO 出库登记复核
    @ResponseBody
    @RequestMapping("/hj/updateWarehouseRegistrationCheck.action")
    public int updateWarehouseRegistrationCheck(@RequestBody SPayView sPayView) throws Exception {
        return this.sPayService.updateWarehouseRegistrationCheckService(sPayView);
    }
    //TODO 出库查询
    @ResponseBody
    @RequestMapping("/hj/queryOutWarehouse.action")
    public SPaySearch<SPay> queryOutWarehouse(@RequestBody SPaySearch<SPay> sPaySearch) throws Exception {
        System.out.println("-----------------"+this.sPayService.queryOutWarehouseService(sPaySearch));
        return this.sPayService.queryOutWarehouseService(sPaySearch);
    }
}
